//
//  HYTabBar.m
//  自定义tabBar
//
//  Created by students on 16/2/18.
//  Copyright (c) 2016年 1000Phone. All rights reserved.
//

#import "HYTabBar.h"

@implementation HYTabBar
-(void)setHYitems:(NSArray *)HYitems
{
    _HYitems=HYitems;
    CGFloat btnW=self.bounds.size.width/HYitems.count;
    CGFloat btnH=self.bounds.size.height;
    for (int i=0; i<HYitems.count; i++)
    {
        UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
        btn.imageView.backgroundColor=[UIColor redColor];
        btn.contentEdgeInsets=UIEdgeInsetsMake(5, 10, 5, 10);
        btn.imageView.contentMode=UIViewContentModeScaleToFill;
        btn.imageView.clipsToBounds=NO;
        UITabBarItem *item=HYitems[i];
        btn.tag=i;
        btn.frame=CGRectMake(i*btnW, 0, btnW, btnH);
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [btn setImage:item.image forState:UIControlStateNormal];
        [self addSubview:btn];
    }
}
- (void)btnClick:(UIButton *)btn
{
    [self.delegate didBtnClickChangeControl:self Index:btn.tag];
}
@end
